#include <iostream>
#include <vector>

// g++ -g -fsanitize=address -fno-omit-frame-pointer  fsanitizer.cpp

int func() {
std::vector<int> arr;
return arr[1];
}

int main() {
   std::cout<<func()<<std::endl;
}

/*
AddressSanitizer:DEADLYSIGNAL
=================================================================
==20207==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000004 (pc 0x000108e41e63 bp 0x7ff7b70bff00 sp 0x7ff7b70bfe00 T0)
==20207==The signal is caused by a READ memory access.
==20207==Hint: address points to the zero page.
    #0 0x108e41e63 in func() fsanitizer.cpp:8
    #1 0x108e41fa8 in main fsanitizer.cpp:12
    #2 0x7ff80e67441e in start+0x76e (dyld:x86_64+0xfffffffffff6e41e) (BuildId: 2faf54fd58e6360c9bd82fbfe8be93d332000000200000000100000000060d00)

==20207==Register values:
rax = 0x0000000000000004  rbx = 0x00007ff7b70bfe60  rcx = 0x0000100000000000  rdx = 0x00007ff7b70bfd20
rdi = 0x00007ff7b70bfe20  rsi = 0x0000000000000001  rbp = 0x00007ff7b70bff00  rsp = 0x00007ff7b70bfe00
 r8 = 0x0000000108e3f460   r9 = 0x0000000000000000  r10 = 0x0000000000004000  r11 = 0x00007ff7b70bed40
r12 = 0x00007ff7b70c00d8  r13 = 0x00007ff7b70c0110  r14 = 0x00007ff7b70c0120  r15 = 0x00007ff7b70bffa0
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV fsanitizer.cpp:8 in func()
==20207==ABORTING
[1]    20207 abort      ./a.out
*/
